Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deploy preview workflow #904

Merged
merged 11 commits into from
Nov 28, 2024
Merged

Conversation

robbymilo
Copy link
Contributor

@robbymilo robbymilo commented Nov 26, 2024

for https://github.com/grafana/website/issues/10101

This PR deploys a publicly available preview of the output of the make docs command for pull requests. The preview is then deleted when the PR is merged or closed.

To test

  1. Create a branch from this PR
  2. Open a PR
  3. Test the GitHub comment link
  4. Test the link in the GitHub commit checks area
  5. Push a new test commit
  6. Once the deploy preview is updated, make sure the commit is reflected:
curl -Is https://deploy-preview-writers-toolkit-{replace-with-pr}-zb444pucvq-vp.a.run.app | grep build

The output should be the same commit sha as the commit you pushed.

  1. Again test the GitHub link (you should see the comment has been edited)
  2. Close the PR
  3. Confirm the comment is updated with "Deploy preview deleted"
  4. Confirm the preview is actually deleted - it should 404.

Before merge todo:

  • change clone ref branch
  • change workflow ref branch

Copy link
Contributor

github-actions bot commented Nov 26, 2024

@robbymilo robbymilo marked this pull request as ready for review November 26, 2024 14:43
@robbymilo robbymilo requested a review from a team as a code owner November 26, 2024 14:43
Copy link
Member

@jdbaldry jdbaldry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an absolutely incredible feature. Thank you so much for implementing it.

I know you've worked with the Platform team already but I'd like to see if I get one of them to take a look through to check for Actions best practices, primarily from a security perspective, so that we can confidently propagate this across other repositories.

docker run -v ${PWD}/dist:/hugo/dist -v "${PWD}/${{ inputs.source_directory }}:/hugo/${{ inputs.website_directory }}" --rm grafana/docs-base:latest /bin/bash -c 'HUGO_SSI=false hugo --environment=docs --destination=dist/ --baseURL= --minify'
printf "%s" "add_header 'Build' '"${{ inputs.sha }}"';" > build.conf

- uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2.1.7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you use https://github.com/grafana/shared-workflows/tree/main/actions/push-to-gar-docker for this and the following steps without requiring a custom service account?

Copy link
Contributor Author

@robbymilo robbymilo Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service account in login-to-gar (https://github.com/grafana/shared-workflows/blob/main/actions/login-to-gar/action.yaml#L27), which is called from push-to-gar, is hard coded from the output of the construct-service-account step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to explore this in a follow up. I don't mind that the same service account handles all the aspects of this service.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service account in the shared-workflow is currently just an implementation detail and IIRC @dsotirakis is investigating if we can completely get rid of it 🙂 That was the main reason for me asking about this here but it's absolutely not required 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service account in the shared-workflow is currently just an implementation detail and IIRC @dsotirakis is investigating if we can completely get rid of it 🙂 That was the main reason for me asking about this here but it's absolutely not required 🙂

Good to know! I'm subscribed to all activity on the grafana/shared-workflows repository so if something moves there, we'll know :)

Thanks for clarifying

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to come back and update if we can get rid of it!

@robbymilo robbymilo requested review from jdbaldry and zerok November 27, 2024 15:07
Copy link
Member

@jdbaldry jdbaldry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks so good man!

Copy link

@zerok zerok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for porting this over ❤️

@robbymilo robbymilo merged commit 7751d7a into main Nov 28, 2024
5 checks passed
@robbymilo robbymilo deleted the robbymilo/add-deploy-preview-workflow branch November 28, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants